import React, { Component } from 'react';
import { connect } from 'dva';
import { Tabs } from 'antd';
import { Dispatch, AnyAction } from 'redux';
import { RouteComponentProps } from 'react-router-dom';

import styles from './index.css';
import Details from './components/index';
import { isMenuVisible } from '@/utils/utils';
const { TabPane } = Tabs;

interface callpoliceManageProps
  extends RouteComponentProps<{ deviceTypeNo?: string; deviceSonTypeNo?: string }> {
  dispatch: Dispatch<AnyAction>;
}
@connect()
class statics extends Component<callpoliceManageProps> {
  constructor(props: callpoliceManageProps) {
    super(props);
  }
  handleTabChange = (type: string) => {
    const { dispatch } = this.props;
    isMenuVisible('iot:deviceAlam:monitorAnalyze') && dispatch({ type });
  };
  componentWillMount() {
    console.log(this.props);
  }
  render() {
    const { match } = this.props;
    const { deviceTypeNo, deviceSonTypeNo } = match.params;
    return (
      <div className={styles.container}>
        <Tabs onChange={this.handleTabChange} type="card">
          <TabPane tab="报警管理" key="/callpoliceManage">
            {isMenuVisible('iot:deviceAlam:view') && (
              <Details
                deviceId={this.props.location.query.deviceId}
                deviceTypeParentNo={deviceTypeNo}
                deviceTypeNo={deviceSonTypeNo}
              />
            )}
          </TabPane>
        </Tabs>
      </div>
    );
  }
}
export default statics;
